import java.util.ArrayList;
import java.util.List;

public class Student {
    // 学生属性
    private String studentId;    // 学生编号
    private String name;         // 姓名
    private String gender;       // 性别
    private List<Course> selectedCourses = new ArrayList<>();  // 所选课程列表

    // 构造方法
    public Student(String studentId, String name, String gender) {
        this.studentId = studentId;
        this.name = name;
        this.gender = gender;
    }

    // 学生“选课”方法
    public void selectCourse(Course course) {
        selectedCourses.add(course);
        System.out.println(name + " 成功选修课程：" + course.getCourseName());
    }

    // 学生“退课”方法
    public void dropCourse(Course course) {
        if (selectedCourses.remove(course)) {
            System.out.println(name + " 成功退选课程：" + course.getCourseName());
        } else {
            System.out.println(name + " 未选修该课程，退课失败！");
        }
    }

    // 打印学生课表方法
    public void printCourseSchedule() {
        System.out.println("========== " + name + " 的课表 ==========");
        System.out.println("课程编号\t课程名称\t上课地点\t上课时间\t授课教师");
        for (Course course : selectedCourses) {
            Teacher teacher = course.getTeacher();
            System.out.println(course.getCourseId() + "\t" + course.getCourseName() + "\t" + 
                               course.getLocation() + "\t" + course.getTime() + "\t" + 
                               teacher.getName());
        }
        System.out.println("=====================================");
    }

    // Getter方法
    public String getStudentId() {
        return studentId;
    }

    public String getName() {
        return name;
    }

    public String getGender() {
        return gender;
    }

    public List<Course> getSelectedCourses() {
        return selectedCourses;
    }
}